{	Problem: http://codeforces.ru/problemset/problem/12/C
	Verdict: Accepted
}
{$R+,S+,Q+,I+,C+,M+,H+,O-}
uses SysUtils;
var i,n,m,j,ind,c:longint; r:int64; t:string; a,b:array[1..110] of longint; s:array[1..110] of string;
procedure qsort(l,r:longint);
var i,j,x,y:longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2];
repeat
  while a[i]<x do inc(i);
  while a[j]>x do dec(j);
  if i<=j then begin
    y:=a[i];
    a[i]:=a[j];
    a[j]:=y;
    inc(i);
    dec(j);
  end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
procedure qsort_b(l,r:longint);
var i,j,x,y:longint;
begin
i:=l;
j:=r;
x:=b[(l+r) div 2];
repeat
  while b[i]>x do inc(i);
  while b[j]<x do dec(j);
  if i<=j then begin
    y:=b[i];
    b[i]:=b[j];
    b[j]:=y;
    inc(i);
    dec(j);
  end;
until i>j;
if l<j then qsort_b(l,j);
if i<r then qsort_b(i,r);
end;
begin
fillchar(b,sizeof(b),0);
read(n,m);
for i:=1 to n do read(a[i]);
qsort(1,n);
readln;
c:=0;
for i:=1 to m do begin
  readln(t);
  ind:=0;
  for j:=1 to c do
    if s[j]=t then begin
      ind:=j;
      break;
    end;
  if ind=0 then begin
    inc(c);
    s[c]:=t;
    b[c]:=1;
  end else inc(b[ind]);
end;
qsort_b(1,c);
r:=0;
for i:=1 to c do inc(r,b[i]*a[i]);
write(r,' ');
r:=0;
for i:=1 to c do inc(r,b[i]*a[n-i+1]);
write(r);
end.